const Koa = require('koa')
const router = require('koa-route')
const app = new Koa()

const redirect = (ctx) =>{
    ctx.response.redirect('/')
    // ctx.response.body = '<a href ="/">去首页</a>'
}

const main = (ctx) => {
    ctx.response.body = '这是首页'
}

// app.use(main)
app.use(router.get('/',main))  // 定义接口api
app.use(router.get('/redirect',redirect))
app.listen(3000, () => {
  console.log('项目已启动');
})